package sh.orm.convert;

import sh.orm.OrmException;

import java.util.Date;

/**
 * @author lqq
 * @date 2019/2/21
 */
public class TypeConvertorManager {

    /**
     * 根据要转换的目标类型，获取对应的转换器
     * @param targetClass
     * @return
     */
    public static TypeConvertor getTypeConvertor(Class<?> targetClass){
        if(targetClass == Date.class){
            return new DateTypeConvertor();
        }
        //if(targetClass == JDBCType.BIT.getName()){
        //
        //}

    //    TODO 添加所有的数据类型转化

    //    TODO JDBCType 进行判断

    //   如果没有精确匹配到，使用默认的类型转换器，也就是不转换，直接返回
    //    return new AbstractTypeConvertor();
        //    如果没有对应的类型转换器，那么抛出异常
        throw new OrmException("没有对应的类型转换器" + targetClass.getName());
    }
    //
    ///**
    // * Identifies the generic SQL type {@code BIT}.
    // */
    //BIT(Types.BIT),
    ///**
    // * Identifies the generic SQL type {@code TINYINT}.
    // */
    //TINYINT(Types.TINYINT),
    ///**
    // * Identifies the generic SQL type {@code SMALLINT}.
    // */
    //SMALLINT(Types.SMALLINT),
    ///**
    // * Identifies the generic SQL type {@code INTEGER}.
    // */
    //INTEGER(Types.INTEGER),
    ///**
    // * Identifies the generic SQL type {@code BIGINT}.
    // */
    //BIGINT(Types.BIGINT),
    ///**
    // * Identifies the generic SQL type {@code FLOAT}.
    // */
    //FLOAT(Types.FLOAT),
    ///**
    // * Identifies the generic SQL type {@code REAL}.
    // */
    //REAL(Types.REAL),
    ///**
    // * Identifies the generic SQL type {@code DOUBLE}.
    // */
    //DOUBLE(Types.DOUBLE),
    ///**
    // * Identifies the generic SQL type {@code NUMERIC}.
    // */
    //NUMERIC(Types.NUMERIC),
    ///**
    // * Identifies the generic SQL type {@code DECIMAL}.
    // */
    //DECIMAL(Types.DECIMAL),
    ///**
    // * Identifies the generic SQL type {@code CHAR}.
    // */
    //CHAR(Types.CHAR),
    ///**
    // * Identifies the generic SQL type {@code VARCHAR}.
    // */
    //VARCHAR(Types.VARCHAR),
    ///**
    // * Identifies the generic SQL type {@code LONGVARCHAR}.
    // */
    //LONGVARCHAR(Types.LONGVARCHAR),
    ///**
    // * Identifies the generic SQL type {@code DATE}.
    // */
    //DATE(Types.DATE),
    ///**
    // * Identifies the generic SQL type {@code TIME}.
    // */
    //TIME(Types.TIME),
    ///**
    // * Identifies the generic SQL type {@code TIMESTAMP}.
    // */
    //TIMESTAMP(Types.TIMESTAMP),
    ///**
    // * Identifies the generic SQL type {@code BINARY}.
    // */
    //BINARY(Types.BINARY),
    ///**
    // * Identifies the generic SQL type {@code VARBINARY}.
    // */
    //VARBINARY(Types.VARBINARY),
    ///**
    // * Identifies the generic SQL type {@code LONGVARBINARY}.
    // */
    //LONGVARBINARY(Types.LONGVARBINARY),
    ///**
    // * Identifies the generic SQL value {@code NULL}.
    // */
    //NULL(Types.NULL),
    ///**
    // * Indicates that the SQL type
    // * is database-specific and gets mapped to a Java object that can be
    // * accessed via the methods getObject and setObject.
    // */
    //OTHER(Types.OTHER),
    ///**
    // * Indicates that the SQL type
    // * is database-specific and gets mapped to a Java object that can be
    // * accessed via the methods getObject and setObject.
    // */
    //JAVA_OBJECT(Types.JAVA_OBJECT),
    ///**
    // * Identifies the generic SQL type {@code DISTINCT}.
    // */
    //DISTINCT(Types.DISTINCT),
    ///**
    // * Identifies the generic SQL type {@code STRUCT}.
    // */
    //STRUCT(Types.STRUCT),
    ///**
    // * Identifies the generic SQL type {@code ARRAY}.
    // */
    //ARRAY(Types.ARRAY),
    ///**
    // * Identifies the generic SQL type {@code BLOB}.
    // */
    //BLOB(Types.BLOB),
    ///**
    // * Identifies the generic SQL type {@code CLOB}.
    // */
    //CLOB(Types.CLOB),
    ///**
    // * Identifies the generic SQL type {@code REF}.
    // */
    //REF(Types.REF),
    ///**
    // * Identifies the generic SQL type {@code DATALINK}.
    // */
    //DATALINK(Types.DATALINK),
    ///**
    // * Identifies the generic SQL type {@code BOOLEAN}.
    // */
    //BOOLEAN(Types.BOOLEAN),
    //
    ///* JDBC 4.0 Types */
    //
    ///**
    // * Identifies the SQL type {@code ROWID}.
    // */
    //ROWID(Types.ROWID),
    ///**
    // * Identifies the generic SQL type {@code NCHAR}.
    // */
    //NCHAR(Types.NCHAR),
    ///**
    // * Identifies the generic SQL type {@code NVARCHAR}.
    // */
    //NVARCHAR(Types.NVARCHAR),
    ///**
    // * Identifies the generic SQL type {@code LONGNVARCHAR}.
    // */
    //LONGNVARCHAR(Types.LONGNVARCHAR),
    ///**
    // * Identifies the generic SQL type {@code NCLOB}.
    // */
    //NCLOB(Types.NCLOB),
    ///**
    // * Identifies the generic SQL type {@code SQLXML}.
    // */
    //SQLXML(Types.SQLXML),
    //
    ///* JDBC 4.2 Types */
    //
    ///**
    // * Identifies the generic SQL type {@code REF_CURSOR}.
    // */
    //REF_CURSOR(Types.REF_CURSOR),
    //
    ///**
    // * Identifies the generic SQL type {@code TIME_WITH_TIMEZONE}.
    // */
    //TIME_WITH_TIMEZONE(Types.TIME_WITH_TIMEZONE),
    //
    ///**
    // * Identifies the generic SQL type {@code TIMESTAMP_WITH_TIMEZONE}.
    // */
    //TIMESTAMP_WITH_TIMEZONE(Types.TIMESTAMP_WITH_TIMEZONE);
}
